home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / X11 / Xos.h < prev    next >
C/C++ Source or Header  |  2006-04-12  |  7KB  |  296 lines

  1. /*
  2.  * $XdotOrg: xc/include/Xos.h,v 1.2.4.1 2005/01/12 02:55:30 gisburn Exp $
  3.  * $Xorg: Xos.h,v 1.6 2001/02/09 02:03:22 xorgcvs Exp $
  4.  * 
  5.  * 
  6. Copyright 1987, 1998  The Open Group
  7.  
  8. Permission to use, copy, modify, distribute, and sell this software and its
  9. documentation for any purpose is hereby granted without fee, provided that
  10. the above copyright notice appear in all copies and that both that
  11. copyright notice and this permission notice appear in supporting
  12. documentation.
  13.  
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16.  
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  20. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23.  
  24. Except as contained in this notice, the name of The Open Group shall not be
  25. used in advertising or otherwise to promote the sale, use or other dealings
  26. in this Software without prior written authorization from The Open Group.
  27.  *
  28.  * The X Window System is a Trademark of The Open Group.
  29.  *
  30.  */
  31. /* $XFree86: xc/include/Xos.h,v 3.41tsi Exp $ */
  32.  
  33. /* This is a collection of things to try and minimize system dependencies
  34.  * in a "signficant" number of source files.
  35.  */
  36.  
  37. #ifndef _XOS_H_
  38. #define _XOS_H_
  39.  
  40. #include <X11/Xosdefs.h>
  41.  
  42. /*
  43.  * Get major data types (esp. caddr_t)
  44.  */
  45.  
  46. #ifdef USG
  47. #ifndef __TYPES__
  48. #ifdef CRAY
  49. #define word word_t
  50. #endif /* CRAY */
  51. #include <sys/types.h>            /* forgot to protect it... */
  52. #define __TYPES__
  53. #endif /* __TYPES__ */
  54. #else /* USG */
  55. #if defined(_POSIX_SOURCE) && defined(MOTOROLA)
  56. #undef _POSIX_SOURCE
  57. #include <sys/types.h>
  58. #define _POSIX_SOURCE
  59. #else
  60. #include <sys/types.h>
  61. #endif
  62. #endif /* USG */
  63.  
  64. #ifndef sgi
  65. #if defined(SCO325) || defined(__USLC__)
  66. #include <stdint.h>
  67. #endif
  68. #endif
  69.  
  70. #ifdef _SEQUENT_
  71. /*
  72.  * in_systm.h compatibility between SysV and BSD types u_char u_short u_long
  73.  * select.h  for typedef of args to select, fd_set, may use SVR4 later
  74.  */
  75. #include <netinet/in_systm.h>
  76. #include <sys/select.h>
  77. #endif /* _SEQUENT_ */
  78.  
  79. /*
  80.  * Just about everyone needs the strings routines.  We provide both forms here,
  81.  * index/rindex and strchr/strrchr, so any systems that don't provide them all
  82.  * need to have #defines here.
  83.  *
  84.  * These macros are defined this way, rather than, e.g.:
  85.  *    #defined index(s,c) strchr(s,c)
  86.  * because someone might be using them as function pointers, and such
  87.  * a change would break compatibility for anyone who's relying on them
  88.  * being the way they currently are. So we're stuck with them this way,
  89.  * which can be really inconvenient. :-(
  90.  */
  91.  
  92. #ifndef X_NOT_STDC_ENV
  93.  
  94. #include <string.h>
  95. #ifdef SCO325
  96. #include <strings.h>
  97. #else
  98. #if (defined(sun) && defined(__SVR4))
  99. #include <strings.h>
  100. #endif
  101. #ifdef __STDC__
  102. #ifndef index
  103. #define index(s,c) (strchr((s),(c)))
  104. #endif
  105. #ifndef rindex
  106. #define rindex(s,c) (strrchr((s),(c)))
  107. #endif
  108. #else
  109. #ifndef index
  110. #define index strchr
  111. #endif
  112. #ifndef rindex
  113. #define rindex strrchr
  114. #endif
  115. #endif
  116. #endif
  117.  
  118. #else
  119.  
  120. #ifdef SYSV
  121. #if defined(clipper) || defined(__clipper__)
  122. #include <malloc.h>
  123. #endif
  124. #include <string.h>
  125. #define index strchr
  126. #define rindex strrchr
  127. #else
  128. #include <strings.h>
  129. #define strchr index
  130. #define strrchr rindex
  131. #endif
  132.  
  133. #endif /* X_NOT_STDC_ENV */
  134.  
  135. /*
  136.  * strerror()
  137.  */
  138. #if (defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__)
  139. #ifndef strerror
  140. extern char *sys_errlist[];
  141. extern int sys_nerr;
  142. #define strerror(n) \
  143.     (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error")
  144. #endif
  145. #endif
  146.  
  147. /*
  148.  * Get open(2) constants
  149.  */
  150. #if defined(X_NOT_POSIX)
  151. #include <fcntl.h>
  152. #if defined(USL) || defined(CRAY) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__)
  153. #include <unistd.h>
  154. #endif
  155. #ifdef WIN32
  156. #include <X11/Xw32defs.h>
  157. #else
  158. #include <sys/file.h>
  159. #endif
  160. #else /* X_NOT_POSIX */
  161. #if !defined(_POSIX_SOURCE) && defined(macII)
  162. #define _POSIX_SOURCE
  163. #include <fcntl.h>
  164. #include <unistd.h>
  165. #undef _POSIX_SOURCE
  166. #else
  167. #include <fcntl.h>
  168. #include <unistd.h>
  169. #endif
  170. #endif /* X_NOT_POSIX else */
  171.  
  172. /*
  173.  * Get struct timeval and struct tm
  174.  */
  175.  
  176. #if defined(SYSV) && !defined(_SEQUENT_)
  177.  
  178. #ifndef USL
  179. #include <sys/time.h>
  180. #endif
  181. #include <time.h>
  182. #ifdef CRAY
  183. #undef word
  184. #endif /* CRAY */
  185. #if defined(USG) && !defined(CRAY) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__) && !defined(clipper) && !defined(__clipper__)
  186. struct timeval {
  187.     long tv_sec;
  188.     long tv_usec;
  189. };
  190. #ifndef USL_SHARELIB
  191. struct timezone {
  192.     int tz_minuteswest;
  193.     int tz_dsttime;
  194. };
  195. #endif /* USL_SHARELIB */
  196. #endif /* USG */
  197.  
  198. #ifdef _SEQUENT_
  199. struct timezone {
  200.     int tz_minuteswest;
  201.     int tz_dsttime;
  202. };
  203. #endif /* _SEQUENT_ */
  204.  
  205. #else /* not SYSV */
  206.  
  207. #if defined(_POSIX_SOURCE) && defined(SVR4)
  208. /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
  209. #undef _POSIX_SOURCE
  210. #include <sys/time.h>
  211. #define _POSIX_SOURCE
  212. #elif defined(WIN32)
  213. #include <time.h>
  214. #if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_)
  215. struct timeval {
  216.     long    tv_sec;         /* seconds */
  217.     long    tv_usec;        /* and microseconds */
  218. };
  219. #endif
  220. #include <sys/timeb.h>
  221. #define gettimeofday(t) \
  222. { \
  223.     struct _timeb _gtodtmp; \
  224.     _ftime (&_gtodtmp); \
  225.     (t)->tv_sec = _gtodtmp.time; \
  226.     (t)->tv_usec = _gtodtmp.millitm * 1000; \
  227. }
  228. #elif defined(_SEQUENT_) || defined(Lynx)
  229. #include <time.h>
  230. #elif defined (__QNX__)
  231. typedef unsigned long fd_mask;
  232. /* Make sure we get 256 bit select masks */
  233. #define FD_SETSIZE 256
  234. #include <sys/select.h>
  235. #include <sys/time.h>
  236. #include <time.h>
  237. #else
  238. #include <sys/time.h>
  239. #include <time.h>
  240. #endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
  241.  
  242. #endif /* SYSV */
  243.  
  244. /* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
  245. #if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */
  246. #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
  247. #else
  248. #if defined(SVR4) || defined(VMS) || defined(WIN32)
  249. #define X_GETTIMEOFDAY(t) gettimeofday(t)
  250. #else
  251. #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
  252. #endif
  253. #endif /* XPG4 else */
  254.  
  255. #ifdef __UNIXOS2__
  256. typedef unsigned long fd_mask;
  257. #include <limits.h>
  258. #define MAX_PATH _POSIX_PATH_MAX
  259. #endif
  260.  
  261. #ifdef __GNU__
  262. #define PATH_MAX 4096
  263. #define MAXPATHLEN 4096
  264. #define OPEN_MAX 256 /* We define a reasonable limit.  */
  265. #endif
  266.  
  267. /* use POSIX name for signal */
  268. #if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD) && !defined(ISC)
  269. #define SIGCHLD SIGCLD
  270. #endif
  271.  
  272. #ifdef ISC
  273. #include <sys/bsdtypes.h>
  274. #include <sys/limits.h>
  275. #define NGROUPS 16
  276. #endif
  277.  
  278. #if defined(ISC) || defined(__UNIXOS2__) || \
  279.     (defined(__linux__) && !defined(__GLIBC__)) || \
  280.     (defined(__QNX__) && !defined(UNIXCONN))
  281. /*
  282.  *    Some OS's may not have this
  283.  */
  284.  
  285. #define X_NO_SYS_UN 1
  286.  
  287. struct sockaddr_un {
  288.     short    sun_family;
  289.     char    sun_path[108];
  290. };
  291. #endif
  292.  
  293. #include <X11/Xarch.h>
  294.  
  295. #endif /* _XOS_H_ */
  296.